const DB = require('../tools/mysql')

module.exports = async ctx => {
  const card = await DB('card')
    .join('wish', 'card.wish', '=', 'wish.id')
    .join('music', 'card.music', '=', 'music.id')
    .select('card.title', 'card.wish', 'wish.content as wish_content', 'card.wish_style', 'card.display_url', 'music.url as music_url', 'card.share_url', 'card.float_url', 'card.scroll')
    .where('card.id', ctx.request.body.id)

  const images = await DB('image').select('*').where('card', ctx.request.body.id)

  const wishList = await DB('wish')

  ctx.body = {
    card,
    images,
    wishList
  }
}